package stu.day19_day24.day23;

import java.util.Scanner;

public class hw5 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] s1 = sc.nextLine().split(" ");
        int n = Integer.parseInt(s1[0]);
        int m = Integer.parseInt(s1[1]);
        int k = Integer.parseInt(s1[2]);

        int[][] arr = new int[m][2];
        for(int i=0;i<m;i++){
            String[] s2 = sc.nextLine().split(" ");
            arr[i][0] = Integer.parseInt(s2[0]);
            arr[i][1] = Integer.parseInt(s2[1]);
        }

        int[] preNum = new int[m+1];

        for(int i=0;i<m;i++){
            preNum[i+1] = preNum[i]+arr[i][1]-arr[i][0];
        }

        int maxNum = 0;
        for(int i=0;i<m;i++){
            int left = i;
            int right = m;

            while(left<right){
                int mid = (left+right)/2;
                if((arr[i][0]+k)<=arr[mid][1]){
                    right = mid;
                }else {
                    left = mid+1;
                }
            }

            if(left==m){
                maxNum = Math.max(maxNum,preNum[m]-preNum[i]);
                continue;
            }

            if((arr[i][0]+k)<=arr[left][0]){
                maxNum = Math.max(maxNum,preNum[left]-preNum[i]);
            }else {
                maxNum = Math.max(maxNum,preNum[left]-preNum[i]+(arr[i][0]+k-arr[left][0]));
            }

        }


        System.out.println(maxNum);

    }

}
